#include "n1d_buffer.h"

uint32 getNum(char* &ptr)
{
    uint32 ret = ntohl(*(uint32*)ptr); ptr += sizeof(uint32);
    return ret;
}

const char* getHID(char* &ptr)
{
    const char* ret = ptr;
    ptr += UAP_HID_SIZE;
    return ret;
}

const char* getStr(const char* &ptr, const char *lastChar)
{
    const char* ret = ptr;
    while(*ptr) 
    {  
        ptr++;
        if(ptr>lastChar) return NULL;
    }
    ptr++;

    return ret;
}

void addNum(char* &ptr, uint32 num)
{
    *(uint32*)ptr = htonl(num); ptr += sizeof(uint32);
}

void addStr(char* &ptr, const char* str)
{
    int len = strlen(str);
    strcpy(ptr, str); ptr += len + 1;
}
